<!-- Generated automatically from an XML file of the same name.
     Copyright: Stephen J. Sangwine and Nicolas Le Bihan, 2008-2010.
--><html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>S/SCALAR :: Functions (Quaternion Toolbox Function Reference)
</title><link rel="stylesheet" href="qtfmstyle.css" type="text/css"></head><body><h1>Quaternion Function Reference</h1><h2>S/SCALAR</h2>
<p>Scalar component of a quaternion</p>
<h2>Syntax</h2><p><tt>r = s(q), r = scalar(q)</tt></p>
<h2>Description</h2>
<p>
These two functions extract the scalar component of a quaternion.
The result is a real (or a complex value if the quaternion has
complex components).
</p>
<p>
The two functions differ in their behaviour when given a pure quaternion
(that is a quaternion with no scalar part). The function <tt>s</tt>
raises an error in this circumstance, whereas <tt>scalar</tt> returns
a zero array of the same size as the pure quaternion, with the same class
as the components of the quaternion. For example if the pure quaternion
has components of class <tt>uint8</tt> the array of zeros returned will
also be of class <tt>uint8</tt>.
</p>

<h2>Examples</h2>
<pre>
&gt;&gt; q = eyeq(2)
 
q = 2x2 quaternion array
 
&gt;&gt; s(q)

ans =

     1     0
     0     1

&gt;&gt; scalar(qi)

ans =  0
</pre>

<h2>See Also</h2>QTFM functions: <a href="v.html">v</a>, <a href="v.html">vector</a>, <a href="xyz.html">x</a>, <a href="xyz.html">y</a>, <a href="xyz.html">z</a><br>
<h4>&copy; 2008-2010 Stephen J. Sangwine and Nicolas Le Bihan</h4><p><a href="license.html">License terms.</a></p></body></html>